<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }
    </style>

</head>
<body>
<div id="app">

    <!--查询表单-->
    <el-form :inline="true" :model="brand" class="demo-form-inline">

        <el-form-item label="当前状态">
            <el-select v-model="brand.status" placeholder="活动区域">
                <el-option label="启动" value="1"></el-option>
                <el-option label="禁用" value="0"></el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="企业名称">
            <el-input v-model="brand.companyName" placeholder="企业名称"></el-input>
        </el-form-item>

        <el-form-item label="品牌名称">
            <el-input v-model="brand.brandName" placeholder="品牌名称"></el-input>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
    </el-form>
  <!--批量删除和添加-->

    <div style="margin: 20px 0">
        <el-button type="danger" plain >批量删除</el-button>
        <el-button type="primary" plain  @click="dialogVisible = true" >新增</el-button>
    </div>

<!--添加增加按钮的对话框-->

    <el-dialog
            title="编辑品牌"
            :visible.sync="dialogVisible"
            width="30%">
        <el-form :model="brand" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="品牌名称" prop="name">
                <el-input v-model="brand.brandName"></el-input>
            </el-form-item>

            <el-form-item label="企业名称" prop="name">
                <el-input v-model="brand.companyName"></el-input>
            </el-form-item>

            <el-form-item label="排序" prop="name">
                <el-input v-model="brand.ordered"></el-input>
            </el-form-item>

            <el-form-item label="备注" prop="desc">
                <el-input type="textarea" v-model="brand.description"></el-input>
            </el-form-item>

            <el-form-item label="状态" >
                    <el-switch v-model="brand.status"
                            active-value="1"
                            inactive-value="0">
                    </el-switch>
            </el-form-item>

        </el-form>
        <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="addBrand">确 定</el-button>
    <el-button @click="dialogVisible = false">取 消</el-button>

  </span>
    </el-dialog>

 <!--表格-->
    <template>
        <el-table
                :data="tableData"
                style="width: 100%"
                :row-class-name="tableRowClassName"
                @selection-change="handleSelectionChange">

            <el-table-column
                    type="index"
                    width="50">
            </el-table-column>
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    prop="brandName"
                    label="品牌名称"
                    align="center">
            </el-table-column>
            <el-table-column
                    prop="companyName"
                    label="企业名称"
                    align="center">
            </el-table-column>
            <el-table-column
                    prop="ordered"
                    align="center"
                    label="排序">
            </el-table-column>
            <el-table-column
                    prop="status"
                    align="center"
                    label="当前状态">
            </el-table-column>
            <el-table-column
                    label="操作"
                    align="center">
                <div>
                    <el-button type="primary">修改</el-button>
                    <el-button type="danger">删除</el-button>
                </div>
            </el-table-column>
        </el-table>
    </template>

<!--分页-->
    <div class="block">
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[5, 10, 15, 20]"
                :page-size="100"
                layout="total, sizes, prev, pager, next, jumper"
                :total="100">
        </el-pagination>
    </div>
</div>
<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">

<script>
    new Vue({
        el:"#app",
        data(){
            return {
                currentPage4: 4,
                // 添加增加的对话框 是否可见
                dialogVisible: false,
                // 模型数据
                brand: {
                    id:"",
                    brandName:"",
                    companyName:"",
                    ordered:"",
                    description:"",
                    status:"",
                },
                // 批量
                multipleSelection: [],
                // 表格数据
                tableData: [{
                    brandName : '华为',
                    companyName: '华为有限公司',
                    ordered: '100',
                    status:"1"
                }, {
                    brandName : '三只松鼠',
                    companyName: '三只松鼠有限公司',
                    ordered: '100',
                    status:"1"
                }, {
                    brandName : '京东',
                    companyName: '京东科技有限公司',
                    ordered: '123',
                    status:"1"
                }, {
                    brandName : '小米',
                    companyName: '小米科技有限公司',
                    ordered: '122',
                    status: "1"
                }, {
                    brandName : '鸿星尔克',
                    companyName: '鸿星尔克',
                    ordered: '111',
                    status:"1"
                }, {
                    brandName : '阿里巴巴',
                    companyName: '阿里巴巴',
                    ordered: '12',
                    status:"1"
                }]

            }
        },
        methods: {

            tableRowClassName({row, rowIndex}) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            // 复选框选中后执行的方法
            handleSelectionChange(val) {
                this.multipleSelection = val;
                console.log(this.multipleSelection)
            },
            // 查询方法
            onSubmit() {
                console.log(this.brand);
            },
            // 添加数据
            addBrand() {
                console.log(this.brand)
            },
            // 分页
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            }
        },
    })
</script>

</body>
</html>